<?php defined('SYSPATH') or die('No direct access allowed.');


class Model_Project_View extends ORM {

		// Relationships
	protected $_belongs_to = array('project' => array('model' => 'desktop_project','foreign_key' => 'project_id'),
                                       'user'    => array('model' => 'user', 'foreign_key' => 'user_id'));

        public function get_amount($project_id)
        {
            $amount =  DB::select(array('COUNT("*")', 'total_views'))
                         ->from('project_views')
                         ->where('project_id', '=', $project_id)
                         ->execute()
                         ->get('total_views', 0);

            return $amount;

        }
}